<?php

/**
 * Keyword
 *
 * @author Administrator
 * @version
 */
class Model_Tables_Rtreport extends Zend_Db_Table_Abstract {
    /**
     * The default table name
     */
    protected $_name = 'device_collectinfo';
	/**
	 * 获取设备信息列表
	 * @return array_type
	 */
    public function getDeviceInfoList($type,$start,$end)
    {
        $sql ="SELECT dci_cpu,dci_mem,dci_diskfree,dci_iowait,round(dci_net/8/1024,0) as dci_net,dci_time,dci_live_online,dci_vod_online"
        	." FROM device_collectinfo d";
        if ($type == 0)//日报
        	$sql .= " WHERE date_format(dci_time,'%Y%m%d')=".$start." ORDER BY dci_time ASC;"; 
        else if ($type == 1)//月报
        	$sql .= " WHERE date_format(dci_time,'%Y%m')=".$start." ORDER BY dci_time ASC;"; 
//        	$sql ="SELECT round(avg(dci_cpu),2) as dci_cpu,round(avg(dci_mem),2) as dci_mem,round(avg(dci_diskfree),2) as dci_diskfree,round(avg(dci_net)/8/1024,0) as dci_net,"
//				."date_format(dci_time,'%Y%m%d %H:00') as dci_time,sum(dci_live_online) as dci_live_online,sum(dci_vod_online) as dci_vod_online"
// 				." FROM device_collectinfo d WHERE date_format(dci_time,'%Y%m')=".$start." GROUP BY date_format(dci_time,'%Y%m%d %H:00') ORDER BY dci_time ASC;";
        else if ($type == 2)//时间段
        	$sql .= " WHERE date_format(dci_time,'%Y%m%d') BETWEEN ".$start." AND ".$end." ORDER BY dci_time ASC;"; 
//		echo $sql;exit;
		$result = $this->_db->query($sql)->fetchAll();
		return $result;
    }
    
}
